package cn.topevery.garden.wapi.controller;

import cn.topevery.garden.dal.logic.ProjAuditLogic;
import cn.topevery.garden.entity.dto.ProjAuditDTO;
import hw.topevery.framework.web.JsonResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

/**
 * 审计决算表
 *
 * @author code-generate
 * @date 2022-11-02
 */
@Api(tags = "工程项目-审计决算表")
@RestController
@RequestMapping("/projAudit")
public class ProjAuditController extends BaseController {

    @Autowired
    ProjAuditLogic projAuditLogic;

    /**
     * 新增/编辑 审计决算表信息
     *
     * @param dto
     * @return
     */
    @ApiOperation("新增/编辑 审计决算表信息")
    @PostMapping("/saveOrUpdate")
    public JsonResult<Boolean> saveOrUpdate(@Valid @RequestBody ProjAuditDTO dto) {
        projAuditLogic.insertOrUpdate(getUser().userId, dto);
        return JsonResult.ok(true);
    }

    /**
     * 根据projId获取详情
     *
     * @param projId
     * @return
     */
    @ApiOperation("根据projId获取详情")
    @GetMapping("/getByProjId")
    public JsonResult<ProjAuditDTO> getByProjId(@RequestParam(value = "projId") String projId) {
        return JsonResult.ok(projAuditLogic.getByProjId(projId));
    }
}
